<template>
  <div class="app-container">
    <el-row :gutter="20">
      <el-col size="84">
        <!-- 表单 -->
        <el-card shadow="never" style="border: none;border-radius: 10px">
          <h3> 号码库管理 </h3>
          <el-form :model="form" ref="queryForm" size="small" :inline="true" v-show="showSearch"
                   label-width="68px">
            <el-form-item label="号码" prop="userName">
              <el-input v-model="form.userName" clearable style="width: 200px"
                        @keyup.enter.native="handleQuery"/>
            </el-form-item>
            <el-form-item label="号码标志" prop="location">
              <el-input v-model="form.attribution" clearable style="width: 200px"
                        @keyup.enter.native="handleQuery"/>
            </el-form-item>
            <el-form-item>
              <el-button type="primary" class="submit" size="mini" @click="handleQuery">查询
              </el-button>
              <el-button size="mini" @click="reset" class="reset">重置</el-button>
            </el-form-item>
          </el-form>
          <el-row :gutter="10" class="mb8">
          </el-row>
        </el-card>
        <!-- 用户表格 标记管理 -->
        <el-card style="margin-top: 20px;border: none;border-radius: 10px" shadow="never">
          <el-table v-loading="loading" :data="userList" @selection-change="handleSelectionChange">
            <el-table-column type="selection" width="50" align="center"/>
            <el-table-column label="号码" align="center" key="userId" prop="userId"/>
            <el-table-column label="入库时间" align="center" key="date" prop="date" :show-overflow-tooltip="true"/>
            <el-table-column label="号码标识" align="center" key="location" prop="location"
                             :show-overflow-tooltip="true"/>
            <el-table-column label="有效期" align="center" key="balance" prop="balance"/>
            <el-table-column label="更多" align="center" key="status">
              <template slot-scope="scope">
                <el-button size="mini" type="text"
                           @click="handleCommand('handleResetPwd',scope.row)" style="color: #359ED5">历史记录
                </el-button>
              </template>
            </el-table-column>
          </el-table>
          <!-- 分页 -->
          <pagination
            :total="total"
            :page.sync="queryParams.pageNum"
            :limit.sync="queryParams.pageSize"
            @pagination="userList.length"/>
        </el-card>
      </el-col>
    </el-row>

    <!-- 历史记录 -->
    <el-dialog class="dialog2" title="历史记录" :visible.sync="open" width="1200px" append-to-body>
      <el-table v-loading="loading" :data="conLog" @selection-change="handleSelectionChange">
        <el-table-column type="selection" width="50" align="center"/>
        <el-table-column label="时间" align="center" key="date" prop="date" :show-overflow-tooltip="true"/>
        <el-table-column label="提交人" align="center" key="name" prop="name" :show-overflow-tooltip="true"/>
        <el-table-column label="提交类型" align="center" key="type" prop="type"/>
        <el-table-column label="号码标识" align="center" key="brand" prop="brand"/>
        <el-table-column label="状态" align="center" key="status" prop="status">
          <template slot-scope="scope">
            <span :class="scope.row.status== 0 ? 'red' : 'green'">{{ scope.row.status == 0 ? '未生效' : '生效' }}</span>
          </template>
        </el-table-column>
      </el-table>
    </el-dialog>
  </div>
</template>

<script>

export default {
  name: "User",
  data() {
    return {
      // 遮罩层
      loading: false,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 用户表格数据
      userList: [
        {
          userId: '12345678910',
          date: '2021-10-25 15:01:50',
          location: '疑似诈骗',
          balance: '90天'
        },
        {
          userId: '12345678910',
          date: '2021-10-25 15:01:50',
          location: '报销电话',
          numberBank: '20240201',
          balance: '90天'
        },
        {
          userId: '12345678910',
          date: '2021-10-25 15:01:50',
          location: '山东省青岛市',
          numberBank: '20240201',
          balance: '90天'
        }
      ],
      // 是否显示弹出层
      open: false,
      // 登录日志
      conLog: [
        {
          date: '2021-10-25 15:01:50',
          name: '132000001111',
          type: '标记',
          balance: '5000',
          brand: '疑似诈骗',
          status: 0
        },
        {
          date: '2021-10-25 15:01:50',
          name: '132000001111',
          type: '认证',
          balance: '5000',
          brand: '青岛嘿嘿有限公司',
          status: 1
        },
      ],
      // 表单参数
      form: {
        userName: '', // 账号
        attribution: '',// 号码标志
      },
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
      },
      // 表单校验
      rules: {
        userName: [
          {required: true, message: "用户名称不能为空", trigger: "blur"},
          {min: 2, max: 20, message: '用户名称长度必须介于 2 和 20 之间', trigger: 'blur'}
        ],
      }
    };
  },
  created() {
    this.into()
  },
  methods: {
    /** 取消按钮 */
    cancel() {
      this.open = false;
      this.reset();
    },
    /** 表单重置 */
    reset() {
      this.form = {
        userName: '', // 账号
        attribution: '',// 归属地
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
    },
    /** 多选框选中数据 */
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.userId);
      this.single = selection.length != 1;
      this.multiple = !selection.length;
    },
    /** 更多操作触发 */
    handleCommand(command, row) {
      this.open = true
    },
    into() {
    }
  }
};
</script>
<style lang="scss" scoped>
.active {
  color: #1890ff;
  font-size: 15px;
}

.btn {
  color: #333333;
  font-size: 15px;
}

/* 弹窗样式 */
::v-deep .el-dialog__header {
  background: #F4F4F4 !important;
  border-top-left-radius: 10px !important;
  border-top-right-radius: 10px !important;
}

::v-deep .el-dialog {
  border-top-left-radius: 10px !important;
  border-top-right-radius: 10px !important;
}
</style>
